import Axios from 'axios'
const config = require('../../config.json')


//Axios.defaults.baseURL = config.apiUrl;

// 添加请求拦截器
Axios.interceptors.request.use(function (config) {
    //config.headers.post['Content-Type'] = 'application/json';
    config.headers['X-Requested-With'] = 'XMLHttpRequest';
    let token;
    if(config.method == 'get'){
        token = config.params.token
    }else {
        token = config.data.token
    }
    config.headers['X-Token'] = token;
    return config;
}, function (error) {
    // 对请求错误做些什么
    return Promise.reject(error);
});


export default Axios;
